using System;
using System.Collections.Generic;
using System.Text;
using Sedna.Core.Support;

namespace Sedna.Util
{
    public class SortInfo
    {
        /// <summary>
        /// Used for stable sorting.
        /// Such SortInfo is better to set first in sort list.
        /// </summary>
        private bool isPersistent;
        private String sortField;
        private bool isAsc;

        public string SortField
        {
            get { return sortField; }
        }

        public bool IsAsc
        {
            get { return isAsc; }
            set { isAsc = value; }
        }

        public bool IsPersistent
        {
            get { return isPersistent; }
        }

        public bool IsTemporary
        {
            get { return !isPersistent; }
        }
        
        private SortInfo() {}

        public SortInfo(String sortField, bool isAsc)
            : this(sortField, isAsc, false)
        {
        }

        public SortInfo(String sortField, bool isAsc, bool isPersistent)
        {
            Assert.IsFalse(string.IsNullOrEmpty(sortField), "SortField isn't specified");
            
            this.sortField = sortField;
            this.isAsc = isAsc;
            this.isPersistent = isPersistent;
        }
    }
}
